{php include wl_template('common/header');}
<style>
	.hhf{
		display: inline-block;
		padding: 2px 5px 2px 5px;
		border: 1px orangered solid;
		border-radius: 5px;
		cursor:pointer;
	}
</style>
<ul class="nav nav-tabs" id="myTab">
	<li class="active">
		<a href="#">帖子详情</a>
	</li>
</ul>
<div class="app-content">
	<div class="app-form">
		<form action="" method="post" class="form-horizontal form form-validate">
			<div class="form-group-title">帖子详情</div>
			<div class="form-group" id="de2">
				<label class="col-sm-2 control-label">用户</label>
				<div class="col-md-3 col-xs-3">
					<img src="{php echo tomedia($tiezi['mid']['avatar'])}" class="scrollLoading" height="30px" width="30px" />{$tiezi['mid']['nickname']}
				</div>
				{if $bflag == 1}
				<div class="col-md-2 col-xs-2">
					<a href="javascript:;" class="addblack" inmid = "{$inmid}" style="display: inline-block;padding:5px 10px;background-color: orangered;color: white;border-radius: 8px;">加入黑名单</a>
				</div>
				{/if}
				{if $bflag == 2}
				<div class="col-md-2 col-xs-2">
					<a href="javascript:;" class="deteblack" inmid = "{$inmid}" style="display: inline-block;padding:5px 10px;background-color: lawngreen;color: white;border-radius: 8px;">取消黑名单</a>
				</div>
				{/if}
			</div> 
			<div class="form-group">
				<label class="col-sm-2 control-label">Phone</label>
				<div class="col-sm-9">
					<input type="tel" name="data[phone]"  value="{$tiezi['phone']}" class="form-control" placeholder="请输联系人电话" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">发布时间</label>
				<div class="col-sm-9">
					<div class="form-control-static">
						{php echo tpl_form_field_date('data[createtime]', date('Y-m-d H:i:s', $tiezi['createtime']),true);}
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">类型</label>
				<div class="col-sm-9" id="typeClass">
					{php echo tpl_form_field_category_2level('category', $parent, $children, $tiezi['onetype'], $tiezi['type'])}
				</div>
			</div>
			<div class="form-group" id="keyword" {if !$keyword}style="display:none;"{/if}>
				<label class="col-sm-2 control-label">标签</label>
				<div class="col-sm-9" id="keywordList">
					{loop $keyword $item}
						<label class="checkbox-inline">
							<input type="checkbox" name="keyword[]" value="{$item}" {if in_array($item,$tiezi['keyword'])}checked="checked"{/if}>{$item}
						</label>
					{/loop}
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">分享标题</label>
				<div class="col-sm-9">
					<input type="text" name="data[share_title]"  value="{$tiezi['share_title']}" class="form-control" placeholder="请输出帖子分享标题" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">内容</label>
				<div class="col-sm-9">
					<textarea id="cont" style="height: 250px;" name="data[content]" class="form-control">{$tiezi['content']}</textarea>
<!--					<span class="hhf">换行</span>-->
<!--					<span class="head-info">点击换行按钮会在内容里面添加一个换行符，在前端显示时会直接换行,不再需要回车键换行。</span>-->
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">图片</label>
				<div class="col-sm-9">
					{php echo attachment_select_multi('data[img]',$tiezi['img']);}
				</div>
			</div>
			<div class="form-group" id="video-info">
				<label class="col-sm-2 control-label">视频</label>
				<div class="col-sm-9">
					<div class="input-group">
						<input type="text" value="{$tiezi['video_link']}" name="data[video_link]" class="form-control" autocomplete="off" id="cimg-videourl">
						<span class="input-group-btn">
							<button class="btn btn-default" type="button" data-toggle="selectVideo" data-input="#cimg-videourl" data-img="#pimg-videourl" >选择媒体文件</button>
						</span>
					</div>
					<div class="{if $tiezi['video_link']}show{else}hide{/if}" style="width: 300px;height: 300px;">
						<video style="max-height: 300px;" src="{$tiezi['video_link']}" controls="controls">
							您的浏览器不支持该视频播放，请更新浏览器或更换浏览器。
						</video>
					</div>
				</div>
			</div>

			{if Customized::init('pocket1500') > 0 && empty($bflag)}
			<div class="form-group">
				<label class="col-sm-2 control-label">关联商户</label>
				<div class="col-sm-9">
					<select name ='storeids[]' class="form-control select2" multiple="multiple">
						{loop $storelist $pp}
						<option value="{$pp['id']}" {if in_array($pp['id'],$tiezi['storeid'])} selected {/if} >{$pp['storename']}</option>
						{/loop}
					</select>
					<span class="help-block">关联商户会显示在帖子详情内。</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">查阅帖子金额</label>
				<div class="col-sm-9">
					<div class="bigdata" style="margin-top: 10px;">
						<div class="input-group data-item">
							<span class="input-group-addon">非会员</span>
							<input type="hidden" name="vipleid[]" class="form-control" value="no">
							<input type="number"  name="vipprice[]" class="form-control" value="{$viparray1['no']}">
							<span class="input-group-addon">元(最多保留两位小数)</span>
						</div>
					</div>
					<div class="bigdata" style="margin-top: 10px;">
						<div class="input-group data-item">
							<span class="input-group-addon">[{$_W['wlsetting']['halflevel']['name']}]</span>
							<input type="hidden" name="vipleid[]" class="form-control" value="0">
							<input type="number"  name="vipprice[]" class="form-control" value="{$viparray1[0]}">
							<span class="input-group-addon">元(最多保留两位小数)</span>
						</div>
					</div>
					{loop $levels $lpr}
					<div class="bigdata" style="margin-top: 10px;">
						<div class="input-group data-item">
							<span class="input-group-addon">[{$lpr['name']}]</span>
							<input type="hidden" name="vipleid[]" class="form-control" value="{$lpr['id']}">
							<input type="number"  name="vipprice[]" class="form-control" value="{$viparray1[$lpr['id']]}">
							<span class="input-group-addon">元(最多保留两位小数)</span>
						</div>
					</div>
					{/loop}
					<span class="help-block">价格不填或填0即为免费查阅，填入任意负数表示此等级用户无权查阅，价格保留两位小数。</span>
				</div>
			</div>
			{/if}

			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">帖子数据</label>
				<div class="col-sm-9">
					<div class="input-group">
						<span class="input-group-addon">查看数</span>
						<input type="number" min="0" name="data[look]" class="form-control" value="{$tiezi['look']}" />
						<span class="input-group-addon">次</span>
					<!--	<span class="input-group-addon">点赞数</span>
						<input type="number" min="0" name="data[likenum]" class="form-control" value="{$tiezi['likenum']}" />
						<span class="input-group-addon">个</span>-->
						<span class="input-group-addon">分享数</span>
						<input type="number" min="0" name="data[share]" class="form-control" value="{$tiezi['share']}" />
						<span class="input-group-addon">次</span>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">是否置顶</label>
				<div class="col-sm-9">
					<div class="radio radio-success radio-inline">
						<input onclick="show(1)" type="radio" id="top1" name="data[top]" value="1" {if intval($tiezi[ 'top'])==1 }checked="checked" {/if}>
						<label onclick="show(1)" for="top1"> 是 </label>
					</div>
					<div class="radio radio-success radio-inline">
						<input onclick="show(0)" type="radio" id="top2" name="data[top]" value="0" {if intval($tiezi[ 'top'])==0 }checked="checked" {/if}>
						<label onclick="show(0)" for="top2"> 否 </label>
					</div>
				</div>
			</div>
			<div id="endtime" {if empty($tiezi[ 'top'])} style="display: none;" {/if} class="form-group">
				<label class="col-sm-2 control-label">置顶结束时间</label>
				<div class="col-sm-9">
					{php echo tpl_form_field_date('endtime', date('Y-m-d H:i:s', $tiezi['endtime']),true);}
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">状态</label>
				<div class="col-sm-9">
					<div class="radio radio-success radio-inline">
						<input type="radio" id="status1" name="data[status]" value="0" {if intval($tiezi[ 'status'])==0 }checked="checked" {/if}>
						<label for="status1"> 显示 </label>
					</div>
					<div class="radio radio-success radio-inline">
						<input type="radio" id="status2" name="data[status]" value="2" {if intval($tiezi[ 'status'])==2 }checked="checked" {/if}>
						<label for="status2"> 不通过 </label>
					</div>
					<div class="radio radio-success radio-inline">
						<input type="radio" id="status3" name="data[status]" value="1" {if intval($tiezi[ 'status'])==1 }checked="checked" {/if}>
						<label for="status3"> 审核中 </label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"></label>
				<div class="col-sm-9">
					<input type="submit" name="submit" value="提交" class="btn btn-primary min-width" />
					<input type="hidden" name="token" value="{$_W['token']}" />
				</div>
			</div>
		</form>
		{if $comments}
		<div id="de1" style="margin-top: 6rem;" class="panel panel-default">
			<div class="panel-body">
				<h3 style="margin-top: 0;">帖子回复:</h3>
				<div class="panel-body">
					{loop $comments $index $item}
					<div class="form-group">
						<div class="col-md-10 col-xs-12">
							<div><img src="{php echo tomedia($item['mid']['avatar'])}" class="scrollLoading" height="30px" width="30px" /> {$item['mid']['nickname']} {php echo date('Y-m-d H:i:s',$item['createtime'])} 说： {$item['content']}{if empty($item['mid']['bflag'])}<a href="javascript:;" class="blackmid" mid = "{$item['mid']['id']}" cid="{$item['id']}" style="float: right;">拉黑用户</a>{/if}<a href="javascript:;" class="shanchu" cid="{$item['id']}" style="float: right;margin-right:1rem;">删除评论</a></div>
							{loop $comments[$index]['replys'] $re}
							<div class="form-group" style="margin-top: 10px;">
								<div class="col-md-12 col-xs-12">
									<img src="{php echo tomedia($re['smid']['avatar'])}" class="scrollLoading" height="30px" width="30px" /> {$re['smid']['nickname']} {php echo date('Y-m-d H:i:s',$re['createtime'])} 回复
									<img src="{php echo tomedia($re['amid']['avatar'])}" class="scrollLoading" height="30px" width="30px" /> {$re['amid']['nickname']} 说：{$re['content']}
								</div>
								{if empty($re['smid']['bflag'])}
								<a href="javascript:;" class="blackmid" mid="{$re['smid']['id']}"  style="float: right;position: relative;left: -30px;">拉黑用户</a> - 
								{/if}
								<a href="javascript:;" class="shanchureply" rid="{$re['id']}"  style="float: right;position: relative;left: -30px;margin-right:1rem;">删除回复</a>
							</div>
							{/loop}
						</div>
					</div>
					{/loop}
				</div>
			</div>
		</div>
		{/if}
	</div>
</div>
<script>
	function show(asd){
		if(asd){
			$('#endtime').show();
		}else{
			$('#endtime').hide();
		}
	}
	$('#de2').delegate('.addblack','click',function(e){
		e.stopPropagation();
		var mid = $(this).attr('inmid');
		var inid = "{$id}";
		util.nailConfirm(this, function(state) {
		if(!state) return;
			$.post("{php echo web_url('pocket/Tiezi/addblack')}", { mid : mid ,inid : inid }, function(data){
				if(!data.errno){
				util.tips("添加成功！");
				location.reload();
				}else{
				util.tips(data.msg);
				};
			}, 'json');
		}, {html: '确认把该用户加入黑名单?'});
	});
	$('#de1').delegate('.blackmid','click',function(e){
		e.stopPropagation();
		var mid = $(this).attr('mid');
		var inid = "{$id}";
		util.nailConfirm(this, function(state) {
		if(!state) return;
			$.post("{php echo web_url('pocket/Tiezi/addblack')}", { mid : mid ,inid : inid }, function(data){
				if(!data.errno){
				util.tips("添加成功！");
				location.reload();
				}else{
				util.tips(data.msg);
				};
			}, 'json');
		}, {html: '确认把该用户加入黑名单?'});
	});
	$('#de2').delegate('.deteblack','click',function(e){
		e.stopPropagation();
		var mid = $(this).attr('inmid');
		util.nailConfirm(this, function(state) {
		if(!state) return;
			$.post("{php echo web_url('pocket/Tiezi/deteblack')}", { mid : mid }, function(data){
				if(!data.errno){
				util.tips("取消成功！");
				location.reload();
				}else{
				util.tips(data.msg);
				};
			}, 'json');
		}, {html: '确认把该用户取消黑名单?'});
	});
	$('#de1').delegate('.shanchu','click',function(e){
		e.stopPropagation();
		var id = $(this).attr('cid');
		util.nailConfirm(this, function(state) {
		if(!state) return;
			$.post("{php echo web_url('pocket/Tiezi/deletecomment')}", { id : id }, function(data){
				if(!data.errno){
				util.tips("删除成功！");
				location.reload();
				};
			}, 'json');
		}, {html: '删除评论会删除评论下所有回复并无法恢复，确定？'});
	});
	$('#de1').delegate('.shanchureply','click',function(e){
		e.stopPropagation();
		var id = $(this).attr('rid');
		util.nailConfirm(this, function(state) {
		if(!state) return;
			$.post("{php echo web_url('pocket/Tiezi/deletereply')}", { id : id }, function(data){
				if(!data.errno){
				util.tips("删除成功！");
				location.reload();
				};
			}, 'json');
		}, {html: '确定删除回复？'});
	});

	$('.hhf').click(function () {
		var text = $('#cont').val();
		text = text+"<br/>";
		$('#cont').val(text);
	});

    /**
     * 更换一级分类的操作
     */
    $("#typeClass").on('change','[name="category[parentid]"]',function () {
        $("#keyword").hide();
        $("#keywordList").html('');

		var id = $(this).val();
		var pos = $("#keyword");
		if(id > 0){
			$.post("{php echo web_url('pocket/Tiezi/getKeyword')}",{id:id},function(res){
				if(res.data) {
					var html = '';
					$.each(res.data, function (k, v) {
						html += '<label class="checkbox-inline">\n' +
								'<input type="checkbox" name="keyword[]" value="'+v+'">'+v+'\n' +
								'</label>';
					});
					$("#keywordList").append(html);
					pos.show();
				}else{
					pos.hide();
				}
			},"json");
		}else{
			pos.hide();
		}
    });
    /**
     * 更换二级分类的操作
     */
    $("#typeClass").on('change','[name="category[childid]"]',function () {
        var id = $(this).val();
        var pos = $("#keyword");
        $("#keywordList").html('');
        if(id > 0){
            $.post("{php echo web_url('pocket/Tiezi/getKeyword')}",{id:id},function(res){
                if(res.data) {
                    var html = '';
                    $.each(res.data, function (k, v) {
                        html += '<label class="checkbox-inline">\n' +
                            '<input type="checkbox" name="keyword[]" value="'+v+'">'+v+'\n' +
                            '</label>';
                    });
                    $("#keywordList").append(html);
                    pos.show();
                }else{
                    pos.hide();
                }
            },"json");
        }else{
            pos.hide();
        }
    });
</script>
{php include wl_template('common/footer');}